#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/**
 * Definition for singly-linked list.
 */
struct ListNode {
	int val;
	struct ListNode* next;
};
typedef struct ListNode listNode, *listnode;

bool isPalindrome(struct ListNode* head);

int main()
{
	return 0;
}

bool isPalindrome(struct ListNode* head)
{
	listnode slow = head, fast = head->next;
	while (fast) {
		fast = fast->next;
		if (!fast) break;
		slow = slow->next;
		fast = fast->next;
	}

	listnode p = slow->next, p_next;
	slow->next = NULL;

	while (p) {
		p_next = p->next;
		p->next = slow->next;
		slow->next = p;
		p = p_next;
	}

	p = head;
	p_next = slow->next;
	while (p_next) {
		if (p->val != p_next->val) return false;
		p = p->next;
		p_next = p_next->next;
	}

	return true;
}
